Skip to content

Fix legend border artifact in ppc_freqpoly#537

Closed
utkarshpawade wants to merge 7 commits intostan-dev:masterfrom
utkarshpawade:fix/134/legendborder
Closed

Fix legend border artifact in ppc_freqpoly#537
utkarshpawade wants to merge 7 commits intostan-dev:masterfrom
utkarshpawade:fix/134/legendborder

Conversation

@utkarshpawade
Copy link
Copy Markdown
Contributor

Fixes #134

  • ppc_freqpoly() and ppc_freqpoly_grouped() displayed a visible dark border around the y legend key due to the color aesthetic from geom_area() bleeding into the legend glyph
  • Added guides(fill = guide_legend(override.aes = list(color = NA))) to suppress the outline color in legend keys

Before
image

After
image

Copilot AI review requested due to automatic review settings April 10, 2026 05:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a ggplot2 legend rendering artifact in the posterior predictive check frequency polygon plots (ppc_freqpoly() and, transitively, ppc_freqpoly_grouped()), where the geom_area() outline color was bleeding into the legend key.

Changes:

  • Add a guides(fill = guide_legend(override.aes = list(color = NA))) override to suppress the outline color in the fill legend key for ppc_freqpoly().
  • Document the fix in NEWS.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
R/ppc-distributions.R Overrides legend aesthetics for the fill guide to remove the unwanted border artifact in freqpoly PPC plots (also affects grouped variant via delegation).
NEWS.md Adds a changelog entry describing the legend border artifact fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/ppc-distributions.R
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.18%. Comparing base (9d6a95b) to head (c259afa).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #537   +/-   ##
=======================================
  Coverage   99.18%   99.18%           
=======================================
  Files          35       35           
  Lines        6118     6119    +1     
=======================================
+ Hits         6068     6069    +1     
  Misses         50       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I made one review comment. Also, do we have the same issue with ppd_freqpoly or just the ppc_ version?

Comment thread R/ppc-distributions.R Outdated
@utkarshpawade
Copy link
Copy Markdown
Contributor Author

No, ppd_freqpoly doesn't have the issue, it calls legend_none() (ppd-distributions.R:283) since there's no y vs yrep distinction to show. The legend-border artifact is specific to ppc_freqpoly/ppc_freqpoly_grouped.

@jgabry
Copy link
Copy Markdown
Member

jgabry commented Apr 15, 2026

Thinking about this a bit more, maybe we actually want the border in the plot? For example, with low alpha levels y and yrep can look similar except for the outline. This PR would remove the outline. What do you think?

@utkarshpawade
Copy link
Copy Markdown
Contributor Author

I checked this and guide_legend(override.aes = list(color = NA)) only affects the legend key glyph, not the plot geoms. The geom_area() outlines in the plot are untouched, so the low-alpha distinguishability between y and yrep you mentioned is preserved.
Comparison at alpha = 0.3:

Before:

legend key has a dark border box around the y glyph:
befe

After:

legend key is clean; plot polygons still have their outlines.
afe

@jgabry
Copy link
Copy Markdown
Member

jgabry commented Apr 16, 2026

Ok thanks. However, now I'm also wondering why we would actually want to remove the border in the legend. The border is there because the plot also has a border. So isn't the legend more accurate if it includes the border?

@utkarshpawade
Copy link
Copy Markdown
Contributor Author

yes, you're right Closing this PR as working-as-intended.

@jgabry
Copy link
Copy Markdown
Member

jgabry commented Apr 16, 2026

Ok thanks. Also see here if you haven't seen it yet: #545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

legend border on ppc_freqpoly_grouped

4 participants